/* 
* EncoderHandler.h
*
* Created: 10/4/2013 8:05:35 PM
* Author: brodzki
*/

#ifndef ENCODERHANDLER_H_
#define ENCODERHANDLER_H_

#include "Registers.h"

enum EncoderReadValue { neutral = 0, left = 1, right = 2, click = 3 };

class EncoderHandler
{
	uint8_t   last_;
	Registers fst_;
	Registers snd_;
	Registers btn_;	
	unsigned int fst_bit_;
	unsigned int snd_bit_;
	unsigned int btn_bit_;
	
	void initialize();
	
public:
	EncoderHandler
		(
		 Registers fst, unsigned int fst_bit, 
		 Registers snd, unsigned int snd_bit, 
		 Registers btn, unsigned int btn_bit
		) : last_(0), fst_(fst), snd_(snd), btn_(btn), fst_bit_(fst_bit), snd_bit_(snd_bit), btn_bit_(btn_bit)
	{ 
		initialize(); 
	}
	
	uint8_t read(); 
};

#endif // ENCODERHANDLER_H_
